//
//  MYTabBarViewController.swift
//  swift2.0项目开始
//
//  Created by 龚昕炜 on 16/7/28.
//  Copyright © 2016年 龚昕炜. All rights reserved.
//

import UIKit

class MYTabBarViewController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewController()
        
        let myTabBar = MYTabBar()
        myTabBar.tintColor = UIColor.orangeColor()
        
        setValue(myTabBar, forKey: "tabBar")
    }
    
    func addChildViewController() {
        
        addChildViewController(MYHomeViewController(), imageName: "tabbar_message_center", title: "消息")
        addChildViewController(MYFindViewController(), imageName: "tabbar_home", title: "首页")
        addChildViewController(MYMessageViewController(), imageName: "tabbar_discover", title: "发现")
        addChildViewController(MYSettingViewController(), imageName: "tabbar_profile", title: "我")
    }
    
    func addChildViewController(childController: UIViewController, imageName: String, title: String) {
    
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage = UIImage(named: imageName + "_highlighted")
        childController.title = title
        tabBar.tintColor = UIColor.orangeColor()
        
        let nav = UINavigationController(rootViewController: childController)
        
        addChildViewController(nav)
    }

}
